<?php
/*
 * Page management
 */
class Admin_PageController extends H_Controller_Admin_Action
{
    public function init()
    {
        parent::init(); 
        $this->view->headTitle('CMS | Page');
    }
    
    public function indexAction(){
        $this->view->headTitle(' | List');
        $themOb = new H_Model_Template();      
        $this->view->filterTemplateString = H_Util_FilterExt::toListFilterString($themOb->fetchAll()->toArray(), "id", "template_name");                
    }
    public function putAction() {
    }
    public function postAction() {
    }
    public function  getAction() {
    }
    public function  deleteAction() {
    }
    public function  postDispatch() {
        parent::postDispatch();
        $this->view->selfControlerName = $this->_request->getControllerName();
    }
    public function listAction(){        
        $this->desibleLayout();
    	$start = $this->_request->getParam("start",0);
    	$limit = $this->_request->getParam("limit");
    	$callback = $this->_request->getParam("callback");
    	       
    	
        $filter = Admin_Model_Util_Grid::toFiltersSQL($this->_request->getParam("filter"));
    	$baseModel = new H_Model_Page();        
        $sort = Admin_Model_Util_Grid::toOrderSQL($this->_request->getParam("sort"));                    	
    	$data = $baseModel->fetchAll($filter,$sort,$limit,$start)->toArray();
    	$result = array(
    		'start' => $start,
    		'totalCount' => 200,
    		'data' => $data
    	);
    	if ($callback) {
            header('Content-Type: text/javascript');
            echo $callback . '(' . Zend_Json::encode($result,Zend_Json::TYPE_ARRAY) . ');';
        } else {
            header('Content-Type: application/x-json');
            echo Zend_Json::encode($result,Zend_Json::TYPE_ARRAY);
        }
    }   
    //Action nay chi dung de test lam template tra cuu cho nhung cai khac   
}


